package com.ins.controller;

import com.ins.common.utils.Result;
import com.ins.model.query.Query;
import com.ins.model.vo.ConfigsVO;
import com.ins.model.vo.RecommendInfoVO;
import com.ins.model.vo.RecommendVO;
import com.ins.service.HomeService;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * HomeController
 *
 * @author aa
 * @version 1.0
 * @since 2024/7/15
 */
@RestController
@RequestMapping("/home")
public class HomeController {

    @Resource
    private HomeService homeService;


    @GetMapping("/notice")
    public Result<ConfigsVO> notice() {
        return Result.ok(homeService.configs());
    }


    /**
     * 首页推荐
     *
     * @return {@link Result }<{@link RecommendVO }>
     */
    @GetMapping("/recommend")
    public Result<RecommendVO> recommend() {
        return Result.ok(homeService.recommend());
    }

    @GetMapping("/search")
    public Result<Page<RecommendInfoVO>> search(Query query) {
        return Result.ok(homeService.search(query));
    }

}
